package org.example.basic.Enum;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jiachuanbei
 */

public enum StudentEnum {
    // 枚举值
    ZHANG("张三", 18, "男"),
    LI("李四", 19, "女"),
    WANG("王五", 20, "男");


    @Getter
    private final String name;

    @Getter
    private final Integer age;

    @Getter
    private final String sex;

    private StudentEnum(String name, Integer age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public static List<StudentEnum> getStudentEnumByName(String  name) {
        List<StudentEnum> studentEnums = new ArrayList<>();
        for (StudentEnum studentEnum : StudentEnum.values()){
            if (studentEnum.getName().equals(name)){
                studentEnums.add(studentEnum);
            }
        }
        return studentEnums;
    }

    public static List<StudentEnum> getStudentEnumByAge(Integer age) {
        List<StudentEnum> studentEnums = new ArrayList<>();
        for (StudentEnum studentEnum : StudentEnum.values()){
            if (studentEnum.getAge().equals(age)){
                studentEnums.add(studentEnum);
            }
        }
        return studentEnums;
    }

    public static List<StudentEnum> getStudentEnumBySex(String sex) {
        List<StudentEnum> studentEnums = new ArrayList<>();
        for (StudentEnum studentEnum : StudentEnum.values()){
            if (studentEnum.getSex().equals(sex)){
                studentEnums.add(studentEnum);
            }
        }
        return studentEnums;
    }
}
